import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/group_entity.dart';

GroupEntity $GroupEntityFromJson(Map<String, dynamic> json) {
  final GroupEntity groupEntity = GroupEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    groupEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    groupEntity.msg = msg;
  }
  final List<GroupData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<GroupData>(e) as GroupData).toList();
  if (data != null) {
    groupEntity.data = data;
  }
  return groupEntity;
}

Map<String, dynamic> $GroupEntityToJson(GroupEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension GroupEntityExtension on GroupEntity {
  GroupEntity copyWith({
    int? code,
    String? msg,
    List<GroupData>? data,
  }) {
    return GroupEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

GroupData $GroupDataFromJson(Map<String, dynamic> json) {
  final GroupData groupData = GroupData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    groupData.id = id;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    groupData.type = type;
  }
  final String? num = jsonConvert.convert<String>(json['num']);
  if (num != null) {
    groupData.num = num;
  }
  return groupData;
}

Map<String, dynamic> $GroupDataToJson(GroupData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['type'] = entity.type;
  data['num'] = entity.num;
  return data;
}

extension GroupDataExtension on GroupData {
  GroupData copyWith({
    int? id,
    String? type,
    String? num,
  }) {
    return GroupData()
      ..id = id ?? this.id
      ..type = type ?? this.type
      ..num = num ?? this.num;
  }
}